package cn.wangliang181230.json.parser;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

public class JsonBeanPostProcessor implements BeanPostProcessor {

	@Override
	public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
		if (bean instanceof IJSONParser) {
			if (!(bean instanceof UnifiedExceptionJSONParserProxy)) {
				bean = new UnifiedExceptionJSONParserProxy((IJSONParser) bean);
			}
			JSONUtil.setJsonParser((IJSONParser) bean);
		}
		return bean;
	}

}
